package com.ruoyi.system.controller;

import com.ruoyi.system.domain.SysContracts;
import com.ruoyi.system.service.MatchingService;
import com.ruoyi.system.service.SysContractsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

//@RestController
//@RequestMapping("my")
public class MyTestController {

//    @Autowired
//    RedisTemplate redisTemplate;
//    @Autowired
//    SysContractsService contractsService;
//    @Autowired
//    MatchingService matchingService;

//    @PostConstruct
//    public void preheat(){
//        SysContracts contracts = new SysContracts();
//        contracts.setStatus(0);
//        List<SysContracts> sysContracts = contractsService.selectSysContractsList(contracts);
//        for (SysContracts sysContract : sysContracts) {
//            redisTemplate.opsForZSet().add("matchings:"+sysContract.getScokName()+"-"+sysContract.getFalg(),sysContract,sysContract.getScokPrice().doubleValue());
//        }
//    }
//
//    @RequestMapping("list")
//    public void list(){
//        SysContracts contracts = new SysContracts(
//                null,"9988.HK",1,"admin",
//                "阿里巴巴",new BigDecimal(60.00),9,0,new Date(),1
//        );
//
//        String key="matchings:"+contracts.getScokName()+"-"+contracts.getFalg();
//        Set range = redisTemplate.opsForZSet().range(key, 0, -1);
//        System.out.println(range);
//        System.out.println(range.size());
//        matchingService.matching(contracts,key);
//    }
}
